/**
 * Copyright (c) 2013-Now http://jeesite.com All rights reserved.
 */
package com.jeesite.modules.kj.service;

import java.util.List;

import com.jeesite.modules.kj.entity.MyTeam;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.jeesite.common.entity.Page;
import com.jeesite.common.service.CrudService;
import com.jeesite.modules.kj.entity.KjProjectTeam;
import com.jeesite.modules.kj.dao.KjProjectTeamDao;

/**
 * kj_project_teamService
 * @author hzy
 * @version 2021-07-16
 */
@Service
@Transactional(readOnly=true)
public class KjProjectTeamService extends CrudService<KjProjectTeamDao, KjProjectTeam> {

	/**
	 * 获取单条数据
	 * @param kjProjectTeam
	 * @return
	 */
	@Override
	public KjProjectTeam get(KjProjectTeam kjProjectTeam) {
		return super.get(kjProjectTeam);
	}

	/**
	 * 查询分页数据
	 * @param kjProjectTeam 查询条件
	 * @param kjProjectTeam.page 分页对象
	 * @return
	 */
	@Override
	public Page<KjProjectTeam> findPage(KjProjectTeam kjProjectTeam) {
		return super.findPage(kjProjectTeam);
	}

	/**
	 * 保存数据（插入或更新）
	 * @param kjProjectTeam
	 */
	@Override
	@Transactional(readOnly=false)
	public void save(KjProjectTeam kjProjectTeam) {
		super.save(kjProjectTeam);
	}

	/**
	 * 更新状态
	 * @param kjProjectTeam
	 */
	@Override
	@Transactional(readOnly=false)
	public void updateStatus(KjProjectTeam kjProjectTeam) {
		super.updateStatus(kjProjectTeam);
	}

	/**
	 * 删除数据
	 * @param kjProjectTeam
	 */
	@Override
	@Transactional(readOnly=false)
	public void delete(KjProjectTeam kjProjectTeam) {
		super.delete(kjProjectTeam);
	}

	public List<MyTeam> getProjectTeamByMemberId(KjProjectTeam team){
		return dao.getProjectTeamByMemberId(team);
	}

	@Transactional(readOnly=false)
	public void updateContribute(String id){
		dao.updateContribute(id);
	}


	@Transactional(readOnly=false)
	public void updateContributeMember(KjProjectTeam team){
		team.setIsNewRecord(false);
		Long attentionNum = team.getAttentionNum() == null ? 0L : team.getAttentionNum();
		team.setAttentionNum(attentionNum + 1);
		save(team);
	}
}
